home *** CD-ROM | disk | FTP | other *** search
- /********************************************************\
- CWASTEText.h
-
- by Dan Crevier
- version 1.8
-
- Roms 95/11/08 adapted to THINK C / TCL 1.1.3
- \********************************************************/
-
- #pragma once
-
- #include "CAbstractText.h"
- #include "WASTE.h"
- class CPrinter;
- class CWASTEText;
-
- // better define of WASTE version
- #ifndef WASTE_VERSION
- #ifdef WASTE11
- #define WASTE_VERSION 0x01100000
- #else
- #define WASTE_VERSION 0x01000000
- #endif
- #endif
-
- // #define WASTE_OBJECT_ARCHIVE to 1 if you want to use the WASTE Object Archive
- // If it's 0 and WASTE_OBJECTS is 1, WASTE-TCL will use its own handlers
- // only supported with WASTE 1.1
- #ifndef WASTE_OBJECT_ARCHIVE
- #define WASTE_OBJECT_ARCHIVE 0
- #endif
-
- // #define WASTE_TABS to 1 if you are using the WETabs tab code
- // only supported with WASTE 1.1
- #ifndef WASTE_TABS
- #define WASTE_TABS 0
- #endif
-
- // #define WASTE_AUTO_TABS to 1 if you want CWASTEText objects to
- // automatically have each instance support tabs
- // only supported with WASTE 1.1
- #ifndef WASTE_AUTO_TABS
- #define WASTE_AUTO_TABS 1
- #endif
-
- // #define WASTE_OBJECTS as it's #defined for the compilation of WASTE
- // If it's 0, none of the object code will be included
- // only supported with WASTE 1.1
- #ifndef WASTE_OBJECTS
- #define WASTE_OBJECTS 1
- #endif
- #if WASTE_VERSION == 0x01000000
- #define WASTE_OBJECTS 0
- #endif
-
- #ifdef THINK_C
- #define cmdBlack 11420L
- #define cmdRed 11421L
- #define cmdGreen 11422L
- #define cmdBlue 11423L
- #define cmdCyan 11424L
- #define cmdMagenta 11425L
- #define cmdYellow 11426L
- #else
- long const cmdBlack=11420;
- long const cmdRed=11421;
- long const cmdGreen=11422;
- long const cmdBlue=11423;
- long const cmdCyan=11424;
- long const cmdMagenta=11425;
- long const cmdYellow=11426;
- #endif // THINK_C
-
- class CWASTEText : public CAbstractText
- {
- public:
-
- #if TCL_VERSION >= 0x02000000
- TCL_DECLARE_CLASS
- #endif
-
- // data members
- WEHandle macWE; // handle to WE data
- long spacingCmd; // Line spacing command number
- long alignCmd; // alignment cmd number
- long printPageWidth;
- CPrinter *itsPrinter;
-
- // construction/destruction
-
- #ifndef THINK_C
- CWASTEText();
- CWASTEText(CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth = 0, short aHeight = 0, short aHEncl = 0,
- short aVEncl = 0, SizingOption aHSizing = sizELASTIC,
- SizingOption aVSizing = sizELASTIC, short aLineWidth = -1,
- Boolean aScrollHoriz = FALSE, TextStyle *tStyle = NULL,
- Boolean supportObjects = true, Boolean supportUndo = true,
- Boolean supportDragAndDrop = true, Boolean outlineHighliting = true,
- Boolean drawOffscreen = false);
-
- virtual ~CWASTEText();
- #else
- virtual void Dispose(void);
- #endif // THINK_C
-
- void IWASTEText(CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight, short aHEncl, short aVEncl,
- SizingOption aHSizing, SizingOption aVSizing,
- short aLineWidth,
-
- #ifndef THINK_C
- TextStyle *tStyle = NULL,
- Boolean supportObjects = true,
- Boolean supportUndo = true,
- Boolean supportDragAndDrop = true,
- Boolean outlineHighliting = true,
- Boolean drawOffscreen = false
- #else
- TextStyle *tStyle,
- Boolean supportObjects,
- Boolean supportUndo,
- Boolean supportDragAndDrop,
- Boolean outlineHighliting,
- Boolean drawOffscreen
- #endif // THINK_C
- );
- virtual void IViewTemp(CView *anEnclosure, CBureaucrat *aSupervisor,
- Ptr viewData);
-
- #if WASTE_VERSION >= 0x01100000
- virtual void DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent);
- virtual WEActionKind GetUndoInfo(Boolean *redoFlag);
- virtual void DoUndo(void);
- #else
- CTextEditTask *MakeEditTask( long editCmd);
- CTextStyleTask *MakeStyleTask( long styleCmd);
- #endif
-
- #if WASTE_TABS
- virtual void InstallTabHandlers(void);
- #endif
-
- virtual void AdjustCursor(Point where, RgnHandle mouseRgn);
-
- #if WASTE_VERSION >= 0x01100000
- // drag and drop
- void InstallDragHandlers(void);
- void RemoveDragHandlers(void);
- virtual Boolean DoDrag(EventRecord *theEvent, Point where);
- #endif
-
- // Menu and commands
- virtual void UpdateMenus(void);
- virtual void DoCommand(long theCommand); //mf
-
- // Mouse and Keystrokes
- virtual void DoClick(Point hitPt, short modifierKeys, long when);
- virtual void PerformEditCommand(long theCommand);
-
- // Validation
- virtual void CheckInsertion(long numChars, long styleSize, Boolean useSelection);
-
- // Display
- virtual void Draw(Rect *area);
- virtual void Activate();
- virtual void Deactivate();
- virtual void SetSelection(long selStart, long selEnd, Boolean fRedraw);
- Boolean SetOutlineHighliting(Boolean hilite);
- virtual void SetTextMargin(short margin);
-
- // Text Specification
- virtual short GetChar(long offset);
- virtual void Clear(void);
- virtual void SetTextPtr(Ptr textPtr, long numChars);
- virtual void StopInlineSession(void);
- virtual Handle GetTextHandle(void);
- virtual Handle CopyTextRange(long start, long end);
- virtual void CopyRangeWithStyle(long start, long end, Handle hText,
- StScrpHandle hStyles);
- #if WASTE_VERSION >= 0x01100000
- virtual void CopyRangeWithStyleSoup(long start, long end, Handle hText,
- StScrpHandle hStyles, WESoupHandle hSoup);
- #endif
- virtual void InsertTextPtr(Ptr text, long length, Boolean fRedraw);
- virtual void InsertWithStyle(Ptr text, long length, StScrpHandle hStyles,
- Boolean fRedraw);
- #if WASTE_VERSION >= 0x01100000
- virtual void InsertWithStyleSoup(Ptr text, long length, StScrpHandle hStyles,
- WESoupHandle hSoup, Boolean fRedraw);
- #endif
- virtual void TypeChar(char theChar, short theModifers);
- virtual void Specify(Boolean fEditable, Boolean fSelectable,
- Boolean fStylable);
-
- // Calibrating
- virtual void CalcWERects(void);
- virtual void AdjustBounds(void);
- virtual void ResizeFrame(Rect *delta);
- virtual void InhibitRecal(Boolean inhibit);
- virtual void InhibitRedraw(Boolean inhibit);
-
- virtual void SetLineWidth(short aLineWidth);
-
- virtual long FindLine(long charPos);
- virtual long GetLength(void);
-
- // Text Characteristics
- virtual void SetFontColor(RGBColor *aFontColor); //mf
- virtual void SetFontColorAll(RGBColor *aFontColor); //mf
- virtual void SetFontNumber(short aFontNumber);
- virtual void SetFontNumberAll(short aFontNumber);
- virtual void SetFontNameAll(Str255 aFontName);
- virtual void SetFontStyle(short aStyle);
- virtual void SetFontStyleAll(short aStyle);
- virtual void SetFontSize(short aSize);
- virtual void SetFontSizeAll(short aSize);
- virtual void SetTextMode(short aMode);
- virtual void SetAlignment(short anAlignment);
- virtual void SetAlignCmd(long alignCmd);
- virtual void SetSpacingCmd(long aSpacingCmd);
- virtual void SetTheStyleScrap(long rangeStart, long rangeEnd,
- StScrpHandle styleScrap, Boolean redraw);
- virtual void SetStyle(short mode, TextStyle *newStyle, Boolean redraw);
-
- virtual long GetHeight(long startLine, long endLine);
- virtual long GetCharOffset(LongPt *aPt);
- virtual void GetCharPoint(long offset, LongPt *aPt);
- virtual void GetTextStyle(short *whichAttributes, TextStyle *aStyle);
- virtual StScrpHandle GetTextStyles(void);
- virtual void GetCharStyle(long charOffset, TextStyle *theStyle);
- virtual long GetSpacingCmd(void);
- virtual long GetAlignCmd(void);
- virtual StScrpHandle GetTheStyleScrap(void);
- #if WASTE_VERSION >= 0x01100000
- virtual WESoupHandle GetTheSoup(void);
- #endif
- virtual void GetRunInfo(long offset, WERunInfo *runInfo);
-
- virtual long GetNumLines(void);
- virtual void GetSelection(long *selStart, long *selEnd);
- virtual void HideSelection(Boolean hide, Boolean redraw);
- virtual void GetSteps(short *hStep, short *vStep);
-
- // Printing
- virtual void Paginate(CPrinter *aPrinter, short pageWidth, short pageHeight);
- virtual void AboutToPrint(short *firstPage, short *lastPage);
- virtual void DonePrinting(void);
-
- #if WASTE_VERSION >= 0x01100000
- #if WASTE_OBJECTS
- // Pictures
- virtual void InsertPicture(PicHandle pHandle, Boolean fRedraw);
-
- // Sounds
- virtual void InsertSound(Handle sHandle, Boolean fRedraw);
-
- #if WASTE_OBJECT_ARCHIVE
- // Files
- virtual void InsertFSSpec(FSSpec *theFSSpec, Boolean fRedraw);
- #endif // WASTE_OBJECT_ARCHIVE
- #endif // WASTE_OBJECTS
- #endif // WASTE 1.1
-
- // Cursor
- virtual void Dawdle(long *maxSleep);
-
- // Object I/O
- #if TCL_VERSION >= 0x02000000
- virtual void PutTo(CStream& stream);
- virtual void GetFrom(CStream& stream);
- #endif
-
- static CWASTEText *curWASTEText;
- static pascal void WEPostUpdate(WEHandle hWE, long fixLength, long inputAreaStart,
- long inputAreaEnd, long pinRangeStart, long pinRangeEnd);
- static pascal void WEPreUpdate(WEHandle hWE);
- static pascal Boolean WEClickLoop(WEHandle hWE);
-
- #if WASTE_VERSION >= 0x01100000
- Boolean hasUndoSupport;
- #endif
-
- // temporarily changing selection to all
- virtual void TempSelectAll(void);
- virtual void RestoreSelection(void);
-
- protected:
-
- void IWASTETextX(Boolean supportObjects, Boolean supportUndo, Boolean supportDragAndDrop,
- Boolean outlineHighliting, Boolean drawOffscreen);
-
- #if WASTE_VERSION >= 0x01100000
- Boolean dragHandlersInstalled;
- #endif
-
- short textMargin;
- };
-